package com.soker.user.service;

import com.soker.fan.pojo.Fan;
import com.soker.user.mapper.UserMapper;
import com.soker.user.pojo.History;
import com.soker.user.pojo.User;
import com.soker.video.pojo.Video;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class UserServiceImpl implements UserService{
    @Autowired
    private UserMapper userMapper;
    //验证密码
    public String verifyPasswordByUsername(String username) {
        return userMapper.verifyPasswordByUsername(username);
    }
    //注册(添加用户)
    public void register(User user){
        userMapper.register(user);
    }
    //通过用户名查用户信息
    public User findUserByUsername(String username){return userMapper.findUserByUsername(username);}
    //查询用户是否存在
    public boolean isExsit(String username){
        return userMapper.isExsit(username)==1;
    }
    //根据用户id查询用户信息
    public User findUserById(String uid){return userMapper.findUserById(uid);}
    //根据username查询uid
    public int findUidByUsername(String username){return userMapper.findUidByUsername(username);}
    //得到对应upid对应的粉丝的条目数量
    public int getNumber(int upid){return userMapper.getNumber(upid);}
    //得到upid对应的粉丝
    public List<User> findAllFocus(Map map){return userMapper.findAllFocus(map);}
    //得到对应upid对应的粉丝的条目数量
    public int getNumber2(int upid){return userMapper.getNumber2(upid);}
    //得到upid对应的粉丝
    public List<User> findAllFans(Map map){return userMapper.findAllFans(map);}
    //获得某位up的所有视频的点赞数
    public List getUpZanByid(String upid){return userMapper.getUpZanByid(upid);}
    //获得某位up的所有视频的播放量
    public List getUpBoByid(String upid){return userMapper.getUpBoByid(upid);}
    //得到upid对应的投稿的条目数量
    public int getNumber3(int upid){return userMapper.getNumber3(upid);}
    //得到upid对应的投稿
    public List<Video> findAllTouGao(Map map){return userMapper.findAllTouGao(map);}
    //得到upid对应的投稿的条目数量
    public int getNumber4(int upid){return userMapper.getNumber4(upid);}
    //得到upid对应的投稿
    public List<Fan> findAllZhuiFan(Map map){return userMapper.findAllZhuiFan(map);}
    //得到upid对应的投稿的条目数量
    public int getNumber5(int upid){return userMapper.getNumber5(upid);}
    //得到upid对应的投稿
    public List<Video> findAllCang(Map map){return userMapper.findAllCang(map);}
    //查询当前用户的历史记录
    public List<History> findAllHisByUid(String uid){return userMapper.findAllHisByUid(uid);}
    //删除
    public void deleteHis(Map map){userMapper.deleteHis(map);}
    //批量删除
    public void deleteManyHis(String uid){userMapper.deleteManyHis(uid);}
    //查询当前登录用户是否关注了当前video的up
    public boolean isFans(Map map){return userMapper.isFans(map)==1;}
    //关注up
    public void focusUp(Map map){userMapper.focusUp(map);}
    //取消关注
    public void cancelFocus(Map map){userMapper.cancelFocus(map);}
    //关注数+1
    public void updateUp(String upid){userMapper.updateUp(upid);}
    //关注数+1
    public void updateUp2(String fansid){userMapper.updateUp2(fansid);}
    //关注数-1
    public void cancelUp(String upid){userMapper.cancelUp(upid);}
    //关注数-1
    public void cancelUp2(String fansid){userMapper.cancelUp2(fansid);}
}
